/****************************************************************************************
 Copyright © 2003-2012 ZTEsoft Corporation. All rights reserved. Reproduction or       <br>
 transmission in whole or in part, in any form or by any means, electronic, mechanical <br>
 or otherwise, is prohibited without the prior written consent of the copyright owner. <br>
 ****************************************************************************************/
package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalServiceOfferConsts;
import com.iwhalecloud.bss.kite.cucc.service.pos.handler.CuccPosServiceUtils;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import com.iwhalecloud.bss.kite.service.scene.attr.OperateInstAttrService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <Description> <br>
 *  生效模式
 * @author tengg<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2021年2月25日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.attr.handler <br>
 */

public class FeeEffectiveModeAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {
    @Autowired
    OperateInstAttrService operateInstAttrService;

    @Autowired
    IQuerySceneInstService querySceneInstService;

    @Override
    public void onShow(KiteAttr attr, KiteInst inst, AttrData data) {
        String cateId = CuccPosServiceUtils.getCateId(data.getSceneInstId(), data.getCustId());
        // 行业5G消息 资费变更只展示自定义生效
        if (KiteStringUtils.equalsAny(cateId,"2000966") && LocalServiceOfferConsts.SERVICE_OFFER_FEE_MODIFY.equals(data.getServiceOfferId())) {
            attr.getAttrValues().removeIf(attrVal -> !KiteStringUtils.equals(attrVal.getAttrValue(), LocalKeyConsts.CUSTOM_VALIDATION));
        }
        super.onShow(attr, inst, data);
    }

    @Override
    public void after(KiteAttr attr, KiteInst inst, AttrData data) {
        super.after(attr, inst, data);
        String cateId = CuccPosServiceUtils.getCateId(data.getSceneInstId(), data.getCustId());
        // 行业5G消息 资费变更只能选自定义生效
        if (KiteStringUtils.equalsAny(cateId,"2000966") && LocalServiceOfferConsts.SERVICE_OFFER_FEE_MODIFY.equals(data.getServiceOfferId())) {
            this.set(attr, inst, LocalKeyConsts.CUSTOM_VALIDATION, data);
        }
    }
}
